package com.wwe.kotlinstudy.dm.thirteen;

import java.util.Enumeration;
import java.util.Vector;

/**
 * @name KotlinStudy
 * @package name：com.wwe.kotlinstudy.dm.thirteen
 * @anthor DavidZhang
 * @time 2018/5/21 12:32
 * @class 需要监控的对象列表
 */
public abstract class AbstractSubject implements Subject {

    private Vector<Observer> vector = new Vector<>();

    @Override
    public void add(Observer observer) {
        vector.add(observer);
    }

    @Override
    public void delete(Observer observer) {
        vector.remove(observer);
    }

    @Override
    public void notifyObservers() {
        Enumeration<Observer> enumo = vector.elements();
        while (enumo.hasMoreElements()) {
            enumo.nextElement().update();
        }

    }


}
